package com.example.shop.user.dto;

import com.example.shop.pojo.UserAddressBook;
import com.fasterxml.uuid.Generators;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotEmpty;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AddLinkmanParam {
    //联系人的头像
    protected MultipartFile linkmanPicture;
    //联系人的名字
    @NotEmpty
    protected String linkmanName;
    //联系人电话
    @NotEmpty
    protected String linkmanPhone;
    //联系人地区
    @NotEmpty
    protected String linkmanArea;
    //联系人详细地址
    @NotEmpty
    protected String detailedAddress;

    @Override
    public String toString() {
        return "AddLinkmanParam{" +
                "linkmanPicture=" + linkmanPicture +
                ", linkmanName='" + linkmanName + '\'' +
                ", linkmanPhone='" + linkmanPhone + '\'' +
                ", linkmanArea='" + linkmanArea + '\'' +
                ", detailedAddress='" + detailedAddress + '\'' +
                '}';
    }

    public UserAddressBook getUserAddressBook(){
        UserAddressBook userAddressBook = new UserAddressBook();
        //根据时间随机生成UUID来作为联系人id
        userAddressBook.setLinkmanId(Generators.timeBasedGenerator().generate().node());
        userAddressBook.setLinkmanName(linkmanName);
        userAddressBook.setLinkmanPhone(linkmanPhone);
        userAddressBook.setLinkmanArea(linkmanArea);
        userAddressBook.setDetailedAddress(detailedAddress);
        return userAddressBook;
    }

}
